{extend name="common/main"}

{block name="css"}
<!-- 本页面需要额外添加的css请在此处添加 -->



{/block}

{block name="body"}

<body style="background: rgb(235, 236, 237);position:relative;">
<div class="tab_nav">
    <div class="header">
        <div class="h-left"> <a class="sb-back" href="javascript:history.back(-1)" title="返回"></a> </div>
        <div class="h-mid"> 确认订单 </div>
    </div>
</div>
<div class="screen-wrap fullscreen login">
    <form name="cart2_form" id="cart2_form" >
        <section class="content" style="min-height: 294px;">
            <div class="wrap">
                <div class="active" style="min-height: 294px;">
                    <div class="content-buy">
                        <div class="wrap order-buy">
                            <a href="{:Url('User/address_list',array('source'=>'cart2'))}">
                                <section class="address">
                                    <input type="hidden" name="address_id" value="{$address.address_id}">
                                    <div class="address-info" >收货人:
                                        <p class="address-name">{$address.consignee}</p>
                                        <p class="address-phone">{$address.mobile}</p>
                                    </div>
                                    <div class="address-details">收货地址：{$address.address}</div>
                                    <input type="hidden" value="{$address.address_id}" name="address_id" />
                                </section>
                            </a>
                            <section class="order " id="order4">
                                <div  class="order-info" style="margin-top:0;">
                                    <!--
                                          <h4 class="seller-name" > <img src="__STATIC__/images/flow/dingdan.png" width="28">
                                              订单详情 <a class="modify" href="{:Url('Cart/cart')}">修改</a></h4>
                                    -->
                                </div>
                                <section class="order-info" style=" margin-top:0px;">
                                    <div class="order-list">
                                        <div class="goods-list-title"> 网站自营</div>
                                        <ul class="order-list-info">
                                            {foreach name="cartList" item="v"  key="k"}
                                                {if condition="$v['selected'] eq '1'"}
                                                    <li class="item" >
                                                        <div class="itemPay list-price-nums" id="itemPay17">
                                                            <p class="price">￥{$v.shop_price}元</p>
                                                            <p class="nums">x{$v.goods_num}</p>
                                                        </div>
                                                        <div class="itemInfo list-info" id="itemInfo12">
                                                            <div class="list-img"> <a href="{:url('Classify/goodsinfo')}?id={$v.goods_id}"> <img src="{$v.goods_id|goods_thum_images=100,100}"></a> </div>
                                                            <div class="list-cont">
                                                                <h5 class="goods-title">{$v.goods_name} </h5>
                                                                <p class="godds-specification">{$v.spec_key_name}</p>
                                                            </div>
                                                        </div>
                                                    </li>
                                                {/if}
                                            {/foreach}
                                            <li class="flow_youhui_no">如果是会员<font color=red></font>，可以享受会员折扣价</li>
                                            <li class="flow_youhui_no">
                                                <div class="checkout_other">
                                                    <div class="jmbag" href="javascript:void(0);" onClick="showCheckoutOther(this);"><span class="right_arrow_flow"></span>使用优惠券</div>
                                                    <table class="subbox_other sub_bonus" width="100%">
                                                        <tr>
                                                            <td  colspan="2">
                                                                <input type="radio" class="radio vam ma-ri-10" name="couponTypeSelect" checked value="1"  onClick="ajax_order_price();" />
                                                                <select id="coupon_id" name="coupon_id" class="vam ou-no" onChange="ajax_order_price();">
                                                                    <option value="0">选择优惠券</option>
                                                                    {foreach name="couponList" item="v"  key="k"}
                                                                        <option value="{$v['id']}">{$v['name']}</option>
                                                                    {/foreach}
                                                                </select>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </li>
                                            <li class="flow_youhui_no">
                                                <label id="Bonus_span_0">

                                                    您的可用余额<em>{$user['user_money']}</em>
                                                </label>
                                            </li>
                                        </ul>
                                    </div>
                                </section>
                            </section>
                            <section class="order-info">
                                <div class="order-list">
                                    <div class="content ptop0">
                                        <div class="panel panel-default info-box">
                                            <div class="orderInfo " >
                                                <h4 class="seller-name"> <img src="/mobiled/images/flow/dingdan.png" width="28"> 其他选项 </h4>
                                            </div>
                                            <table border=0 cellpadding=0 cellspacing=0 width="100%" class="checkgoods">
                                                <tr>
                                                    <td colspan=4 class="tdother2" style="border-top:none;"><div class="checkout_other" >
                                                        <div class="jmbag" href="javascript:void(0);" onClick="showCheckoutOther(this);"><span class="right_arrow_flow"></span>开发票和备注</div>
                                                        <div class="subbox_other" width="100%">
                                                            <table id='normal_invoice_tbody' width="100%">
                                                                <tr>
                                                                    <td align=right style="vertical-align:top" width="84">发票抬头：</td>
                                                                    <td colspan="2">
                                                                        <input class="txt1" style='vertical-align:middle' type="text" name="invoice_title" placeholder="XXX单位 或 XX个人" />
                                                                    </td>

                                                                </tr>
                                                                <tr>
                                                                    <td align=right style="vertical-align:top" width="84">备注：</td>

                                                                    <td>
                                                                        <input style='vertical-align:middle' type="text" name="user_note" placeholder="输入备注">
                                                                    </td>

                                                                </tr>

                                                            </table>
                                                        </div>
                                                    </div>
                                                    </td>
                                                </tr>
                                            </table>
                                            <div style="height:10px; line-height:10px; clear:both;"></div>
                                        </div></div></div>
                            </section>
                            <section class="order-info">
                                <div class="order-list">
                                    <div class="content ptop0">
                                        <div class="panel panel-default info-box">
                                            <div class="con-ct fo-con">
                                                <ul class="ct-list order_total_ul" id="ECS_ORDERTOTAL" >
                                                    <!--<li class="order_total_li" >-->
                                                        <!--*该订单完成后，您将获得 <span class="price">相应的</span> 积分<br/>-->
                                                    <!--</li>-->
                                                    <li>
                                                        <div class="subtotal">
                                                            <span class="total-text">商品总额：</span><em class="price">￥{$total_price.total_fee}元</em><br/>
                                                            <span class="total-text">会员折扣价：</span><em class="price">￥{$total_price.total_fee*$total_price.discount}</em>元<br/>
                                                            <span class="total-text">配送费用：</span>￥<em class="price" id="postFee">{$total_price.shipping_price}</em>元<br/>
                                                            <span class="total-text">使用优惠券：</span>-&nbsp;¥&nbsp;<em class="price" id="couponFee">0</em>元<br/>
                                                            <!--<span class="total-text">使用积分：</span>-&nbsp;¥&nbsp;<em class="price" id="pointsFee">0</em>元<br/>-->
                                                            <!--<span class="total-text">使用余额：</span>-&nbsp;¥&nbsp;<em class="price" id="balance">0</em>元<br/>-->
                                                            <!--<span class="total-text">优惠活动：</span>-&nbsp;¥&nbsp;<em class="price" id="order_prom_amount">0</em>元<br/>-->
                                                            <span class="total-text">应付金额：</span>￥<strong class="price_total" id="payables">{$total_price.order_amount}</strong>元
                                                            <span class="total-text" style=""></span>
                                                        </div>
                                                    </li>
                                                </ul>
                                            </div>
                                            <div class="panel panel-default info-box">
                                                <div class="pay-btn">
                                                    <input onClick="roleSubmit();" type="button" class="sub-btn btnRadius" value="提交订单"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </section>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </form>
</div>
<section class="f_mask" style="display: none;"></section>
<include file="Public/footer"/>

</body>



{/block}

{block name="js"}
<!-- 本页面需要额外添加的js请在此处添加 -->
<script src="/assets/js/jquery-1.10.2.js"></script>
<script src="/layer/layer.js"></script>
<script>
    //提交订单
    function roleSubmit() {
        var form = document.getElementById("cart2_form");
        var formData = new FormData(form);
        $.ajax({
            url: "{:Url('addorder')}",
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success: function (res) {
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 400, icon: 1}, function(){
                    //选中是否结算订单
                    layer.confirm("现在就去付款？", {btn: ["去付款","在看看"], shade: 0.5}, function(){
                        // 删除权限组
                        window.location.href="{:url('pay')}?order_id="+res.data.orderAddId;//去支付页面

                        // window.location.href=document.referrer; //返回上一个页面并刷新
                    });

                });
            }
        })
    }



    // 获取订单价格
    function ajax_order_price()
    {
        $.ajax({
            type : "POST",
            url:"{:url('Classify/cart')}",
            data : $('#cart2_form').serialize(),
            dataType: "json",
            success: function(data){

//                if(data.status != 1)
//                {
//                    alert(data.msg);
//                    // 登录超时
//                    if(data.status == -100)
//                        location.href ="{:url('mobile/User/login')}";
//
//                    return false;
//                }
                 console.log(data);
//                $("#postFee").text(data.result.postFee); // 物流费
                $("#couponFee").text(data.data.money);// 优惠券
//                $("#balance").text(data.result.balance);// 余额
//                $("#pointsFee").text(data.result.pointsFee);// 积分支付
                $("#payables").text({$total_price.order_amount}-data.data.money);// 应付
//                $("#order_prom_amount").text(data.result.order_prom_amount);// 订单 优惠活动
            }
        });
    }
</script>


{/block}